package com.fdb.efp.nls.service.impl;

import com.fdb.basic.framework.core.base.FrameworkService;
import com.fdb.efp.nls.service.dao.ArpBdWroffDao;
import com.fdb.efp.nls.service.domain.ArpBdWroff;
import com.fdb.efp.nls.service.facade.ArpBdWroffService;
import com.fdb.efp.nls.service.vo.ArpBdWroffVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * <p>
 * 呆账核销台账的Service实现类
 * </p>
 * @author yusys
 * @createDate 2018-06-19 16:10:09
 */
@Service("arpBdWroffService")
public class ArpBdWroffServiceImpl implements ArpBdWroffService, FrameworkService {
    
    private static Logger logger = LoggerFactory.getLogger(ArpBdWroffServiceImpl.class);
    
    @Autowired
    private ArpBdWroffDao arpBdWroffDao;
    
    @Override
    public int insertArpBdWroff(ArpBdWroffVO inArpBdWroffVo) {
        logger.debug("当前新增数据为：" + inArpBdWroffVo.toString());
        int count = 0;
        try {
            ArpBdWroff arpBdWroff = new ArpBdWroff();
            beanCopy(inArpBdWroffVo, arpBdWroff);
            count = arpBdWroffDao.insertArpBdWroff(arpBdWroff);
        } catch (Exception e) {
            logger.error("新增数据发生异常！", e);
            count = -1;
        }
        logger.debug("当前新增数据条数为：" + count);
        return count;
    }
    
    @Override
    public int deleteByPk(ArpBdWroffVO inArpBdWroffVo) {
        logger.debug("当前删除数据条件为：" + inArpBdWroffVo.toString());
        int count = 0;
        try {
            ArpBdWroff arpBdWroff = new ArpBdWroff();
            beanCopy(inArpBdWroffVo, arpBdWroff);
            count = arpBdWroffDao.deleteByPk(arpBdWroff);
        } catch (Exception e) {
            logger.error("删除数据发生异常！", e);
            count = -1;
        }
        logger.debug("根据条件：" + inArpBdWroffVo + "删除的数据条数为" + count);
        return count;
    }
    
    @Override
    public int updateByPk(ArpBdWroffVO inArpBdWroffVo) {
        logger.debug("当前修改数据为：" + inArpBdWroffVo.toString());
        int count = 0;
        try {
            ArpBdWroff arpBdWroff = new ArpBdWroff();
            beanCopy(inArpBdWroffVo, arpBdWroff);
            count = arpBdWroffDao.updateByPk(arpBdWroff);
        } catch (Exception e) {
            logger.error("修改数据发生异常！", e);
            count = -1;
        }
        logger.debug("根据条件：" + inArpBdWroffVo + "修改的数据条数为" + count);
        return count;
    }
    
    @Override
    public ArpBdWroffVO queryByPk(ArpBdWroffVO inArpBdWroffVo) {
        logger.debug("当前查询参数信息为：" + inArpBdWroffVo);
        try {
            ArpBdWroff arpBdWroff = new ArpBdWroff();
            beanCopy(inArpBdWroffVo, arpBdWroff);
            ArpBdWroff queryarpBdWroff = arpBdWroffDao.queryByPk(arpBdWroff);
            if (Objects.nonNull(queryarpBdWroff)) {
                ArpBdWroffVO outArpBdWroffVo = beanCopy(queryarpBdWroff, new ArpBdWroffVO());
                logger.debug("当前查询结果为：" + outArpBdWroffVo.toString());
                return outArpBdWroffVo;
            } else {
                logger.debug("当前查询结果为空！");
            }
        } catch (Exception e) {
            logger.error("查询数据发生异常！", e);
        }
        return null;
    }
    
    @Override
    public ArpBdWroffVO queryByConditon(ArpBdWroffVO inArpBdWroffVo) {
        logger.debug("当前查询参数信息为：" + inArpBdWroffVo);
        try {
            ArpBdWroff arpBdWroff = new ArpBdWroff();
            beanCopy(inArpBdWroffVo, arpBdWroff);
            ArpBdWroff queryarpBdWroff = arpBdWroffDao.queryByConditon(arpBdWroff);
            if (Objects.nonNull(queryarpBdWroff)) {
                ArpBdWroffVO outArpBdWroffVo = beanCopy(queryarpBdWroff, new ArpBdWroffVO());
                logger.debug("当前查询结果为：" + outArpBdWroffVo.toString());
                return outArpBdWroffVo;
            } else {
                logger.debug("当前查询结果为空！");
            }
        } catch (Exception e) {
            logger.error("查询数据发生异常！", e);
        }
        return null;
    }

}